package com.sky.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.sky.dto.OrdersPageQueryDTO;
import com.sky.entity.Orders;
import com.sky.mapper.OrdersAdminMapper;
import com.sky.result.PageResult;
import com.sky.service.OrdersAdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class OrdersAdminServiceImpl implements OrdersAdminService {
    @Autowired
    OrdersAdminMapper ordersAdminMapper;

    @Override
    public PageResult page(OrdersPageQueryDTO ordersPageQueryDTO) {
        PageHelper.startPage(ordersPageQueryDTO.getPage(), ordersPageQueryDTO.getPageSize());
        List<Orders> ordersList = ordersAdminMapper.page(ordersPageQueryDTO);
        PageInfo<Orders> pageInfo = new PageInfo<>(ordersList);
        long total = pageInfo.getTotal();
        return new PageResult(total, ordersList);
    }
}
